package com.senpai.ikhtiar;

import com.senpai.database.Answer;
import com.senpai.database.DatabaseHelper;
import com.senpai.database.Question;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class TestActivity extends ActionBarActivity {
	
	DatabaseHelper database = new DatabaseHelper(this);
	Question question = new Question();
	TextView id,num,ques,category,date;
	TextView id2,name,id_answer;
	Answer answer = new Answer();
	
	int count;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		
		id = (TextView) findViewById(R.id.id);
		num = (TextView) findViewById(R.id.num);
		ques = (TextView) findViewById(R.id.ques);
		category = (TextView) findViewById(R.id.category);
		date = (TextView) findViewById(R.id.date);
		id2 = (TextView) findViewById(R.id.id_parti);
		name = (TextView) findViewById(R.id.name_parti);
		id_answer = (TextView) findViewById(R.id.id_answer);
		
		question = database.getQuestion(21);
		
		answer = database.getAnswer(21);
		
		count = database.match();
		
		//id.setText(Integer.toString(question.getId()));
		id.setText(Integer.toString(count));
		num.setText(question.getNum());
		ques.setText(question.getQuestion());
		category.setText(question.getCategory());
		date.setText(question.getDate());
		
		id2.setText(Integer.toString(answer.getId()));
		name.setText(answer.getParti());
		id_answer.setText(answer.getId_answer());
		
		
		
	}
	
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		Intent intent = new Intent(TestActivity.this,MainActivity.class);
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.test, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
